package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.ArchiveUtilizationStats;
import com.ruoyi.system.mapper.ArchiveUtilizationStatsMapper;
import com.ruoyi.system.service.ArchiveUtilizationStatsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 档案利用统计 Service 实现类
 * 具体实现业务逻辑，事务控制等
 *
 * @author [你的名字或团队名]
 */
@Service
public class ArchiveUtilizationStatsServiceImpl implements ArchiveUtilizationStatsService {

    @Autowired
    private ArchiveUtilizationStatsMapper statsMapper;

    @Override
    public List<ArchiveUtilizationStats> selectArchiveUtilizationStatsList(ArchiveUtilizationStats stats) {
        return statsMapper.selectArchiveUtilizationStatsList(stats);
    }

    @Override
    public ArchiveUtilizationStats selectArchiveUtilizationStatsById(Long id) {
        return statsMapper.selectArchiveUtilizationStatsById(id);
    }

    @Override
    public int insertArchiveUtilizationStats(ArchiveUtilizationStats stats) {
        return statsMapper.insertArchiveUtilizationStats(stats);
    }

    @Override
    public int updateArchiveUtilizationStats(ArchiveUtilizationStats stats) {
        return statsMapper.updateArchiveUtilizationStats(stats);
    }

    @Override
    public int deleteArchiveUtilizationStatsById(Long id) {
        return statsMapper.deleteArchiveUtilizationStatsById(id);
    }

    @Override
    public int deleteArchiveUtilizationStatsByIds(Long[] ids) {
        return statsMapper.deleteArchiveUtilizationStatsByIds(ids);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int batchSaveArchiveUtilizationStats(List<ArchiveUtilizationStats> list) {
        // 1. 删除所有旧数据
        statsMapper.deleteAllArchiveUtilizationStats();
        // 2. 批量插入新数据
        return statsMapper.batchInsertArchiveUtilizationStats(list);
    }
}